<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面渲染</title>
</head>

<body>
    <div id="app">
        <!-- 字符串模板引擎 -->
        姓名:{{username}}
        年龄:{{userage}}
        成绩:{{grade}}

    </div>
</body>
<script>
    // var app = document.getElementById("#app");

    function Vue(options) {

        this.target = document.querySelector(options.el);

        // this.target.innerHTML = this.target.innerHTML.replace("{{username}}", options.data.username);
        // this.target.innerHTML = this.target.innerHTML.replace("{{userage}}", options.data.userage);



        let data = options.data;
        let attrs = Object.keys(data);

        attrs.forEach(attr => {
            this.target.innerHTML = this.target.innerHTML.replace(`{{${attr}}}`, data[attr])
        });


    }

    new Vue({
        el: "#app",
        data: {
            username: "BILL",
            userage: 18,
            grade: 100,
        }


    })




</script>

</html>